package com.lcw.lostandfound.mapper;

import com.lcw.lostandfound.pojo.Comment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface CommentMapper {
    //根据创建时间倒序来排
    List<Comment> findByGoodsIdParentIdNull(@Param("goodsId") Integer goodsId, @Param("parentId") Integer parentId);

    //查询一级回复
    List<Comment> findByGoodsIdParentIdNotNull(@Param("goodsId") Integer goodsId, @Param("id") Integer id);

    //查询二级回复
    List<Comment> findByGoodsIdAndReplayId(@Param("goodsId") Integer goodsId,@Param("childId") Integer childId);

    //添加一个评论
    int saveComment(Comment comment);

    //删除评论
    int deleteComment(Integer commentId);
}
